package LeetCode.month01.day29;

import java.util.HashSet;
import java.util.Set;

public class No1461 {
    public static void main(String[] args) {
        System.out.println(hasAllCodes("00110110", 2));
    }
    public static boolean hasAllCodes(String s, int k) {
        Set<String> exist = new HashSet<>();
        char[] c = s.toCharArray();
        int n = s.length();
        if(k>n) return false;
        StringBuilder sb = new StringBuilder(s.substring(0,k));
        exist.add(sb.toString());
        for (int i = k; i < n; i++) {
            sb=sb.deleteCharAt(0).append(c[i]);
            exist.add(sb.toString());
        }
        if(exist.size()==Math.pow(2,k)) return true;
        return false;
    }
}
